<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    //通过构造函数继承属性
        function Father(name,age){
            this.name=name;
            this.age=age;
        }
        function Son(name,age){
            Father.call(this,name,age);
        }
        var son=new Son("张三",18);
        console.log(son);

    //通过原型对象继承方法
        Father.prototype.money=function(){
            console.log(1000000);
        }
        Son.prototype=new Father();//指向Father实例对象，Father实例对象指向原型对象（方法)
        Son.prototype.constructor=Son;//constructor要指回Son
        Son.prototype.exam=function(){
            console.log("要考试");
        }
        console.log(Son.prototype);//对的，不用怀疑
    </script>
</body>
</html>